﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <th class="formTitle"><span class="required">*</span>名称：</th>
                <td class="formValue">
                    <input id="ypdwmc" name="ypdwmc" type="text" class="form-control required" placeholder="请输入名称" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>编码：</th>
                <td class="formValue">
                    <input id="ypdwCode" name="ypdwCode" type="text" class="form-control required" placeholder="请输入编码" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序：</th>
                <td class="formValue">
                    <input id="px" name="px" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">状态：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        if (!!keyValue) {
            $.najax({
                url: "/PharmacyDrugStorage/SysMedicineUnit/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
        else {
            $.najax({
                url: "/HOME/GetNewFieldUniqueValue?orgIdIsStar=true&topOrgIdIsStar=true&initFieldLength=8&fieldName=xt_ypdw.ypdwCode&r=" + Math.random(),
                dataType: "json",
                cache: false,
                success: function (data) {
                    $('#ypdwCode').val(data.data);
                }
            });
        }
    });
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/PharmacyDrugStorage/SysMedicineUnit/submitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function (data) {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }

</script>